package model;

import controller.exceptions.InvalidVersionException;
import controller.exceptions.ItemAlreadyRemovedException;
import filesystem.Assistants;
import filesystem.exceptions.InvalidModelItemException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * The base model class
 */
public class BaseModel {

    private ArrayList items = new ArrayList();
      
    public ArrayList getItems() {
        return items;
    }

    /**
     * Add object to the model
     *
     * @param item new object
     */
    public void addItem(ModelItem item) throws InvalidModelItemException, 
            IOException {
        items.add(item);
        Assistants.getFileAssistant(item).addItem(item);
    }

    /**
     * Remove object from the model
     *
     * @param item removing object
     */
    public void removeItem(ModelItem item) throws InvalidModelItemException, 
            IOException {
        items.remove(item);
        Assistants.getFileAssistant(item).removeItem(item.getId());
        Assistants.tFA.resetLoaded();
    }

    protected void setItems(ArrayList items) {
        this.items = items;
    }

    
}
